package com.quick.system.service.impl;

import java.util.List;

import com.quick.system.domain.DutyLeave;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.quick.system.mapper.DutyNoticeMapper;
import com.quick.system.domain.DutyNotice;
import com.quick.system.service.IDutyNoticeService;

/**
 * 值班通知Service业务层处理
 * 
 * @author quick
 * @date 2025-01-03
 */
@Service
public class DutyNoticeServiceImpl implements IDutyNoticeService 
{
    @Autowired
    private DutyNoticeMapper dutyNoticeMapper;
    @Autowired
    private DutyLeaveServiceImpl dutyLeaveServiceImpl;

    /**
     * 查询值班通知
     * 
     * @param id 值班通知主键
     * @return 值班通知
     */
    @Override
    public DutyNotice selectDutyNoticeById(Long id)
    {
        return dutyNoticeMapper.selectDutyNoticeById(id);
    }

    /**
     * 查询值班通知列表
     * 
     * @param dutyNotice 值班通知
     * @return 值班通知
     */
    @Override
    public List<DutyNotice> selectDutyNoticeList(DutyNotice dutyNotice)
    {
        return dutyNoticeMapper.selectDutyNoticeList(dutyNotice);
    }

    /**
     * 新增值班通知
     * 
     * @param dutyNotice 值班通知
     * @return 结果
     */
    @Override
    public int insertDutyNotice(DutyNotice dutyNotice)
    {
        return dutyNoticeMapper.insertDutyNotice(dutyNotice);
    }

    /**
     * 修改值班通知
     * 
     * @param dutyNotice 值班通知
     * @return 结果
     */
    @Override
    public int updateDutyNotice(DutyNotice dutyNotice)
    {
        String info = dutyNotice.getInfo();
        if (!info.isEmpty()) {
            DutyLeave dutyLeave = new DutyLeave();
            dutyLeave.setLeaveReason(info);
            dutyLeaveServiceImpl.insertDutyLeave(dutyLeave);
        }
        return dutyNoticeMapper.updateDutyNotice(dutyNotice);
    }

    /**
     * 批量删除值班通知
     * 
     * @param ids 需要删除的值班通知主键
     * @return 结果
     */
    @Override
    public int deleteDutyNoticeByIds(Long[] ids)
    {
        return dutyNoticeMapper.deleteDutyNoticeByIds(ids);
    }

    /**
     * 删除值班通知信息
     * 
     * @param id 值班通知主键
     * @return 结果
     */
    @Override
    public int deleteDutyNoticeById(Long id)
    {
        return dutyNoticeMapper.deleteDutyNoticeById(id);
    }
}
